package com.mayikt;

/**
 * @ClassName Test34
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test34 {
    private static Object lock = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            System.out.println("我是子线程:1");
            synchronized (lock) {
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                ;
            }
            System.out.println("我是子线程:2");
        });
        t1.start();
        try {
            Thread.sleep(3000);
        } catch (Exception e) {

        }
        System.out.println("我是主线程，唤醒子线程");
        synchronized (lock) {
            lock.notify();
        }



    }
}
